home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7959 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: newsserver.amsinc.com!usenet
  2. From: Chris Corry <christopher_corry@mail.amsinc.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: A Number class
  5. Date: Thu, 15 Feb 1996 12:07:06 -0500
  6. Organization: American Management Systems, Inc.
  7. Message-ID: <3123683A.7928@mail.amsinc.com>
  8. NNTP-Posting-Host: ccorry.amsinc.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  13.  
  14. I posted this question awhile ago and no one bit, so I'll try it again
  15. (_I_ think it's an interesting question <g>):
  16.  
  17. I recall reading a few years ago -- in an issue of C++ Report, I believe --
  18. a columnist arguing rather persuasively that writing a Number class, and
  19. getting it right, is actually quite difficult. By "right" I mean with full
  20. operator, precedence, and behavior semantics (i.e., everywhere I can use
  21. say, an int, I should be able to use a Number). I'm interested in exactly
  22. what makes this so hard. I can think of a few things but the most
  23. damaging (and yes, it is pretty minor) is that array initializer semantics
  24. could not be maintained.
  25.  
  26.     // Legal
  27.     int    IntArray[] = { 12, 23, 34, 45, 56 };
  28.  
  29.     // Illegal
  30.     Number NumArray[] = { 12, 23, 34, 45, 56 };
  31.  
  32.  
  33.  
  34. =====================================================================
  35.            Chris Corry, Principal
  36.                   American Management Systems, Inc.
  37.                          christopher_corry@mail.amsinc.com
  38. =====================================================================
  39.